/*
 * @Author: zxc
 * @Date: 2020-08-02 12:36:49
 * @LastEditTime: 2020-08-02 12:48:50
 * @LastEditors: zxc
 * @Description: 是否回文字符串
 */ 
import Deque from './deque';
const IsHuiWenString = (str) => {
  if(str === undefined || str ===null){
    throw new Error('请传入正确的参数')
  }
  const deque = new Deque();
  const lowerStr = str.toLocaleLowerCase().split(' ').join('');
  let isEqual = true;
  let firstChar,lastChar
  for(let i = 0;i< lowerStr.length;i++){
    deque.addBack(lowerStr.charAt(i))
  }
  while(deque.size() > 1 && isEqual){
    firstChar = deque.removeFront()
    lastChar = deque.removeBack()
    isEqual = firstChar === lastChar ? true :false
  }
  return isEqual
}

console.log(IsHuiWenString('abaa'))